function Ball() {
	this.posX = 120;
	this.posY = 80;
	this.velX = 2;
	this.velY = 2;
	
	function update() {
		// Move the ball.
		this.posX = this.posX + this.velX;
		this.posY = this.posY + this.velY;
		if (this.posX < 0) {
			this.velX = this.velX * -1;
			this.posX = 0;
		}
		if (this.posY < 0) {
			this.velY = this.velY * -1;
			this.posY = 0;
		}
		if (this.posX > 240) {
			this.velX = this.velX * -1;
			this.posX = 240;
		}
		if (this.posY > 160) {
			this.velY = this.velY * -1;
			this.posY = 160;
		}	
	};
	this.update = update;
	
	function render(processing) {
		processing.ellipse(this.posX, this.posY, 70, 70);
	};
	this.render = render;
}

function initializeCanvas(canvasElementId) {
	var canvas = document.getElementById(canvasElementId);  
	var processingInstance = new Processing(canvas, renderProcessing);
}

function renderProcessing(processing) {
	processing.size(240, 160);
	processing.smooth();
	processing.fill(
		processing.random(0, 255),
		processing.random(0, 255),
		processing.random(0, 255));
	var ball = new Ball();
	var r, g, b;
	r = processing.random(0, 255);
	g = processing.random(0, 255);
	b = processing.random(0, 255);
 	processing.draw = function() {  
 		processing.background(r, g, b);	
 		ball.update();
 		ball.render(processing);
 	};
}